package com.demo.controller;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 视图模板
 * Created by hui on 2017/12/4.
 */

@Controller
public class HelloController {
    private Logger logger = Logger.getLogger(HelloController.class);

    /*
    *   http://localhost:8099/hello?name=hui
     */

    @RequestMapping("/hello")
    public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
        logger.info("hello");
        model.addAttribute("name", name);
        return "hello";
    }

    @RequestMapping("/he")
    public String say(Map<String,Object> map){
        map.put("name","haha");
        return "he";
    }
}
